//
// Created by Gorun on 2022/5/2.
//

#ifndef LOXPP_TOKENTYPE_H
#define LOXPP_TOKENTYPE_H

#include <string>
using namespace std;

enum TokenType {
    // Single-character tokens.
    LEFT_PAREN=0, RIGHT_PAREN, LEFT_BRACE, RIGHT_BRACE,
    COMMA, DOT, MINUS, PLUS, SEMICOLON, SLASH, STAR,

    // One or two character tokens.
    BANG, BANG_EQUAL,
    EQUAL, EQUAL_EQUAL,
    GREATER, GREATER_EQUAL,
    LESS, LESS_EQUAL,
    QUESTION, COLON,

    // Literals.
    IDENTIFIER, STRING, NUMBER,

    // Keywords.
    AND, CLASS, ELSE, FALSE, FUN, FOR, IF, NIL, OR,
    PRINT, RETURN, SUPER, THIS, TRUE, VAR, WHILE,
    // Lox++ Keywords.
    PRINTLN, INPUT,

    END
};

inline string toString(TokenType type) {
    static const char* type_str[] = {
            "LEFT_PAREN", "RIGHT_PAREN", "LEFT_BRACE", "RIGHT_BRACE",
            "COMMA", "DOT", "MINUS", "PLUS", "SEMICOLON", "SLASH", "STAR",

            // One or two character tokens.
            "BANG", "BANG_EQUAL",
            "EQUAL", "EQUAL_EQUAL",
            "GREATER", "GREATER_EQUAL",
            "LESS", "LESS_EQUAL",
            "QUESTION", "COLON",

            // Literals.
            "IDENTIFIER", "STRING", "NUMBER",

            // Keywords.
            "AND", "CLASS", "ELSE", "FALSE", "FUN", "FOR", "IF", "NIL", "OR",
            "PRINT", "RETURN", "SUPER", "THIS", "TRUE", "VAR", "WHILE",

            // Lox++ Keywords.
            "PRINTLN", "INPUT",

            "END"
    };
    return type_str[static_cast<int>(type)];
}


#endif //LOXPP_TOKENTYPE_H
